package com.cq.smartelebicycle.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.cq.smartelebicycle.R;
import com.cq.smartelebicycle.SpeedActivity;
import com.cq.smartelebicycle.view.SpeedView;


public class SpeedFragment extends Fragment{
	
	public static final String TAG_ID = "SpeedFragment";
	
	public static final int JUMP_TO_FULL_SCREEN = 1;
	public static final int JUMP_TIME = 10 * 1000;
	
	private SpeedView mSpeedView;
	
	private Handler mHandler = new Handler(){
		
		public void handleMessage(Message msg) {
			
			Intent intent = new Intent(getActivity(), SpeedActivity.class);
			getActivity().startActivity(intent);
		}
	};

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view = inflater.inflate(R.layout.speed_fragment, container,false); 
		mSpeedView = (SpeedView) view.findViewById(R.id.speedView);
		return view;
	}
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);

	}
	
	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		mHandler.sendEmptyMessageDelayed(JUMP_TO_FULL_SCREEN, JUMP_TIME);
	}
	
	@Override
	public void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		mHandler.removeMessages(JUMP_TO_FULL_SCREEN);
	}

	
	

}
